angular.module('mychat2').directive('ctrlEnterBreakLine',function(){
	return function(scope,element,attrs){
		var ctrlDown = false;
		element.bind('keydown',function(event){
			console.log(event.which);
			if(event.which === 17){
				ctrlDown = true;
				setTimeout(function(){
					ctrlDown = false;
				},1000);
			}
			if(event.which === 13){
			console.log(event.which);
				if(ctrlDown){
					element.val(element.val()+'\n');
				}else{
					console.log('enter');
					scope.$apply(function(){
						scope.$eval(attrs.ctrlEnterBreakLine);
					});
			event.preventDefault();
			}
		}
		});	
	}
});